package com.mj.myvirtualapp.hooktest;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.os.RemoteException;
import android.util.Log;

public class RemoteService extends Service {

    private final String TAG = "RemoteService";

    @Override
    public void onCreate() {
        super.onCreate();
        Log.e(TAG, "onCreate sleep 21秒" + Thread.currentThread().getName());
        try {
            Thread.sleep(20000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        Log.e(TAG, "onCreate sleep finish" + Thread.currentThread().getName());
    }

    @Override
    public IBinder onBind(Intent intent) {
        Log.e(TAG, "onBind " + Thread.currentThread().getName());
        return new IMyAidlInterface.Stub() {
            @Override
            public int add(int a, int b) throws RemoteException {
               return sum(a, b);
            }
        };
    }

    public int sum(int a, int b) {
        Log.e(TAG, "sum " + Thread.currentThread().getName());
        return a + b;
    }
}
